<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>循环遍历数组</title>
    <style>
        *{margin: 0;padding: 0;list-style-type: none;}
    </style>
</head>
<body>
    <div class="wrap">
        
    </div>
    <script>
        let ulGoodsList = document.querySelector(".wrap")
        let arrGoodsList = [
            {
                //模板
                img_src: "./images/goods1.png",
                goods_id: 4544,
                goods_price: 100,
                goods_title: "辣椒酱"
            },
            {},
            {},
            {},
            {},
            {}
        ]
        let eleStr = "";
            len = arrGoodsList.length;
        for(let i = 0;i < len; ++i){
            //后端传参数
            eleStr += `
                <li>
                    <img src="${arrGoodsList[i].img_src}" alt="">
                    <p class="title">${arrGoodsList[i].goods_title}</p>
                    <p class="price">${arrGoodsList[i].goods_price}元</p>
                </li>
            `
        }
        ulGoodsList.innerHTML = eleStr;
    </script>
</body>
</html>